<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:include page="../include/header.jsp"></jsp:include>
<script type="text/javascript">
   $(function(){
	   var url = "jqGrid/queryPage/url_resource_mgr_list.do";
	   $("#jqGrid").jqGridUtils({
			"url":url,
			"colModel":[{label: "ID",name: "id", hidden:true, key:true},
			            {label: "资源名称" ,name: "resName",width:200},
			            {label: "URL" ,name: "url",width:250},
			            {label: "资源类型" ,name: "resType",width:100},
			            {label: "操作列表" ,name: "operateFlag",width:100},
			            {label: "状态" ,name: "state",width:100},
			            {label: "创建时间" ,name: "createTime",width:150}],
			//caption: "资源管理",
			tableTitleIcon: "fa-th",
			"gridview":true,
			"rowNum":${pageSize},
			tableStyle:"table table-bordered",
			"scrollrows":true,
			multiselect: true,
			toolbar:[true,"top","#jqGrid-search"],
			"datatype":"json",
			"pager":"#jqGridPager"
		});
	   $("#jqGrid").jqGrid('navGrid','#jqGridPager',
			   {add:true,addfunc: function(){
				   //弹出窗口
				   window.parent.BootstrapDialogUtil.loadUriSubmitDialog('添加资源', 'url/resource/add.do?jqGridId=jqGrid', 'fa fa-plus', null, null, function(){
					   window.parent.MixElementListener.initEvent();
				   });
			   }, edit:true,editfunc: function(){
				   //获取选中数据
				   var id = $("#jqGrid").jqGrid('getGridParam','selrow');
				   id = utils.handleNull(id);
				   if(utils.isEmpty(id)) {
					   window.parent.BootstrapDialogUtil.warningAlert(null,"请选择一条要编辑的数据！");
				   } else {
					   window.parent.BootstrapDialogUtil.loadUriSubmitDialog('修改资源', 'url/resource/edit.do?id='+id+'&jqGridId=jqGrid', 'fa fa-pencil-square-o', null, null, function(){
						   window.parent.MixElementListener.initEvent();
					   });
				   }
			   }, del:true,delfunc:function(){
				 //获取选中数据
				   var ids = $("#jqGrid").jqGrid('getGridParam','selarrrow');
				 if(ids.length == 0) {
					 window.parent.BootstrapDialogUtil.warningAlert(null,"请选择一条要删除的数据！");
				 } else {
					 window.parent.BootstrapDialogUtil.delDialog(null,"选中的资源",'url/resource/delete.do',ids.join(','),function(){
						 //$("#jqGrid").trigger("reloadGrid");
						 refreshJqGrid();
					 });
				 }
			   }, view:false, search:false},{id:'edit'},{id:'add'});
	   $(".mix-jqgrid-search").click(function(){
		   var $form = $(this).parents("form:eq(0)");
		   var params = $form.serialize();
		   $("#jqGrid").jqGrid('setGridParam',{url:url+"?"+params,page:1}).trigger("reloadGrid"); //重新载入  
	   });
   });
   //刷新列表
   function refreshJqGrid() {
	   $("#jqGrid").trigger("reloadGrid");
   }
</script>
    <table id="jqGrid"></table>
    <div id="jqGridPager"></div>
    <div class="search-panel" id="jqGrid-search">
      <form class="form-inline">
      	 <div class="form-group">
		    <label for="input01">名称</label>
		    <input type="text" name="name" class="form-control input-sm" id="input01" placeholder="资源名称" />
		 </div>
		  <div class="form-group">
		    <label for="input02">资源类型</label>
		    <select name="type" id="input02" class="mix-select form-control input-sm" data-uri="dict/items/url_resource_type.do">
		       <option value="">所有</option>
		    </select>
		  </div>
		  <button type="button" class="btn btn-info btn-sm mix-jqgrid-search"><i class="fa fa-search"></i> 搜索</button>
      </form>
    </div>
<jsp:include page="../include/footer.jsp"></jsp:include>
